
clear all

//////////////////////////////////////////////////////////////////////////
//		PAYSON (2020) CITY GOVERNMENT LOBBYING
////////////////////////////////////////////////////////////////////////////////

/// This file imports data from Payson (2020) on city-level lobbying. I construct an indicator lobby = 1 if county contains a city that lobbies state government in a given year


/// Download lobbying data for census places here: 
// https://dataverse.harvard.edu/dataset.xhtml?persistentId=doi:10.7910/DVN/MYF97D
// File is called panel.csv 


/// Download 2010 ANSI Codes for Places here:
//https://www.census.gov/library/reference/code-lists/ansi.2010.html#list-tab-230474085
// This is a crosswalk for census places and census counties 


import delim "$InputPath/Payson_panel.csv", clear

keep year statefips placefips lobby

replace lobby="" if lobby=="NA" 
destring lobby, replace

keep if year==2006 | year==2007 | year==2011 | year==2012 // keep relevant fiscal year

replace year=2007 if year==2006 
replace year=2012 if year==2011 

rename (statefips placefips) (fstate fplace)

replace fplace=fplace-fstate*100000

collapse (max) lobby, by(year fstate fplace)

tempfile lobbying
save `lobbying', replace 

//import delim fplace_fcounty_crosswalk.txt, clear  delim("|") 
import delim geocorr2022_2414609193.csv, clear 

rename (v1 v2 v3) (fcounty fstate fplace )
drop if _n<3

replace fcounty=substr(fcounty,-3,3)
destring fcounty fstate fplace, replace

merge m:m fstate fplace using `lobbying'

keep if _m==3


collapse (max) lobby , by(year fstate fcounty)

cd "$OutputPath"

save Payson_Lobbying.dta, replace
